package com.ruoyi.boat.service.impl;

import com.ruoyi.boat.aop.MyDataScope;
import com.ruoyi.boat.aop.SQLFilter;
import com.ruoyi.boat.domain.AlertHistory;
import com.ruoyi.boat.mapper.AlertHistoryMapper;
import com.ruoyi.boat.service.IAlertHistoryService;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 告警历史Service业务层处理
 *
 * @author ruoyi
 * @date 2023-08-01
 */
@Service
public class AlertHistoryServiceImpl implements IAlertHistoryService {
    @Autowired
    private AlertHistoryMapper alertHistoryMapper;

    /**
     * 查询告警历史
     *
     * @param id 告警历史主键
     * @return 告警历史
     */
    @Override
    public AlertHistory selectAlertHistoryById(Long id) {
        return alertHistoryMapper.selectAlertHistoryById(id);
    }

    /**
     * 查询告警历史列表
     *
     * @param alertHistory 告警历史
     * @return 告警历史
     */
    @Override
    @MyDataScope
    @SQLFilter
    public List<AlertHistory> selectAlertHistoryList(AlertHistory alertHistory) {
        return alertHistoryMapper.selectAlertHistoryList(alertHistory);
    }

    /**
     * 新增告警历史
     *
     * @param alertHistory 告警历史
     * @return 结果
     */
    @Override
    public int insertAlertHistory(AlertHistory alertHistory) {
        alertHistory.setCreateTime(DateUtils.getNowDate());
        return alertHistoryMapper.insertAlertHistory(alertHistory);
    }

    /**
     * 修改告警历史
     *
     * @param alertHistory 告警历史
     * @return 结果
     */
    @Override
    public int updateAlertHistory(AlertHistory alertHistory) {
        return alertHistoryMapper.updateAlertHistory(alertHistory);
    }

    /**
     * 批量删除告警历史
     *
     * @param ids 需要删除的告警历史主键
     * @return 结果
     */
    @Override
    public int deleteAlertHistoryByIds(String ids) {
        return alertHistoryMapper.deleteAlertHistoryByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除告警历史信息
     *
     * @param id 告警历史主键
     * @return 结果
     */
    @Override
    public int deleteAlertHistoryById(Long id) {
        return alertHistoryMapper.deleteAlertHistoryById(id);
    }
}
